#include "clientsocket.h"
ClientSocket::ClientSocket(qintptr handle, QObject * server):QTcpSocket (server)
{
    this->setSocketDescriptor(handle);
    //客户端有数据到达channelReadyRead
    connect(this, SIGNAL(readyRead()), this, SLOT(slotReadClientData()));
    connect(this, SIGNAL(disconnected()), this, SLOT(slotClientDisconnected()));



} //客户端断开连接

//可读
void ClientSocket::slotReadClientData(){
    //读取数据
    QByteArray array  = readAll();
    QString s(array);
    //发送信息
    emit receiveData(this, s);
}
//连接断开
void ClientSocket::slotClientDisconnected(){
    emit clientDisconnected(this);
}
